solved compiled warnings, issue #96
authorJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 16 May 2018 11:55:10 +0000 (13:55 +0200)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 16 May 2018 11:55:10 +0000 (13:55 +0200)
src/siri/db/query.c
src/siri/db/re.c
src/siri/db/server.c
src/siri/parser/listener.c
src/siri/siri.c
src/strextra/strextra.c

index c170eaa1f81014f98fe42fbc2b443d8950cd1445..a50311adeed65dbe8d15cf18f282396c439c6690 100644 (file)
@@ -1016,6 +1016,7 @@ static int QUERY_rebuild(
             }
             return 0;
         }
+    /* FALLTHRU */
     /* no break */
     default:
         {
index 4d666544079d1baff3a49300d10bebd568580963..18fde412253f31fca96a272dc1b27449b8e48cb8 100644 (file)
@@ -42,6 +42,7 @@ int siridb_re_compile(
     case 'i':
         options |= PCRE2_CASELESS;
         len--;
+        /* FALLTHRU */
         /* no break */
     case '/':
         pattern[len] = '$';
index 0e30b40d14e04d2b8eb65b312dec05deb9a2f7a5..3de59181d878fd31572db4594634649f27dd2afe 100644 (file)
@@ -891,6 +891,7 @@ int siridb_server_drop(siridb_t * siridb, siridb_server_t * server)
 #endif
         pool->server[0] = pool->server[1];
         pool->server[0]->id = 0;
+        /* FALLTHRU */
         /* no break */
     case 1:
         pool->server[1] = NULL;
index 2affffa34855b8ba240973d806ddf4bfc0e85915..7a64bc02a5e4a575801532913e7a155064df7acd 100644 (file)
@@ -5638,6 +5638,7 @@ static void master_select_work(uv_work_t * work)
     {
     case -1:
         sprintf(query->err_msg, "Memory allocation error.");
+        /* FALLTHRU */
         /* no break */
     case 1:
         query->flags |= SIRIDB_QUERY_FLAG_ERR;
index 9b4b9ddb7bf2ebc842eddd7ca36fd47f23eec214..ad8d8eefb832e2d68a7845e8c68b12802cc682ba 100644 (file)
@@ -17,6 +17,9 @@
  *      siri->siridb_list :    read (lock)          write (not allowed)
  *
  */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <assert.h>
 #include <logger/logger.h>
 #include <qpack/qpack.h>
@@ -248,7 +251,7 @@ static int SIRI_load_databases(void)
 {
     DIR * db_container_path;
     struct dirent * dbpath;
-    char buffer[SIRI_PATH_MAX];
+    char * buffer;
 
     if (!xpath_is_dir(siri.cfg->default_db_path))
     {
@@ -279,16 +282,21 @@ static int SIRI_load_databases(void)
             continue;
         }
 
-        snprintf(buffer,
-                SIRI_PATH_MAX,
+        if (asprintf(
+                &buffer,
                 "%s%s/",
                 siri.cfg->default_db_path,
-                dbpath->d_name);
+                dbpath->d_name) < 0)
+        {
+            /* allocation error occurred */
+            log_critical("Could not allocate space for database path");
+            continue;
+        }
 
         if (!siridb_is_db_path(buffer))
         {
             /* this is not a SiriDB database directory, files are missing */
-            continue;
+            goto next;
         }
 
         if (siri.siridb_list->len == MAX_NUMBER_DB)
@@ -298,13 +306,15 @@ static int SIRI_load_databases(void)
                     "are allowed on a single SiriDB process.",
                     dbpath->d_name,
                     MAX_NUMBER_DB);
-            continue;
+            goto next;
         }
 
         if (siridb_new(buffer, 0) == NULL)
         {
             log_error("Could not load '%s'.", dbpath->d_name);
         }
+next:
+        free(buffer);
     }
     closedir(db_container_path);
 
index 356a76327df955d946e914f3e70e38742f951191..0a3f96019917d22050c4838d43351d76704061a2 100644 (file)
@@ -294,6 +294,7 @@ double strx_to_double(const char * src, size_t len)
         break;
     case '+':
         pt++;
+        /* FALLTHRU */
         /* no break */
     default:
         convert = 1.0;